home *** CD-ROM | disk | FTP | other *** search
/ Mac Magazin/MacEasy 11 / Mac Magazin and MacEasy Magazine CD - Issue 11.iso / Sharewarebibliothek / Entwickler / ThreadLibrary-1.0 / Interfaces / ThreadLibraryManager.h < prev    next >
Text File  |  1995-06-08  |  5KB  |  117 lines

  1. /* See the file Distribution for distribution terms.
  2.     (c) Copyright 1994-1995 Ari Halberstadt */
  3.  
  4. /*    Header for the Thread Library Manager compatability layer. The layer provides
  5.     a very similar functional interface to Apple's Thread Manager.
  6.  
  7.     You can use the macros THREAD_MANAGER_AS_THREAD_LIBRARY and THREAD_LIBRARY_AS_THREAD_MANAGER
  8.     to replace one functional interface with the other. For instance, if you have an
  9.     application written using Thread Manager, and you want to try using Thread Library,
  10.     you can just include this header file in all source files that make calls to Thread
  11.     Manager.
  12.  
  13.     Define THREAD_MANAGER_AS_THREAD_LIBRARY as 1 to enable macros that redefine Thread
  14.     Manager function calls to equivalent Thread Library Manager function calls. This
  15.     is the default if you include this file.
  16.     
  17.     Define THREAD_LIBRARY_AS_THREAD_MANAGER as 1 to enable macros that redefine Thread
  18.     Library Manager function calls to equivalent Thread Manager function calls. */
  19.     
  20. #pragma once
  21. #ifndef THREAD_LIBRARY_MANAGER
  22. #define THREAD_LIBRARY_MANAGER
  23.  
  24. #ifndef __THREADS__
  25. #include <Threads.h>
  26. #endif
  27.  
  28. #ifdef __cplusplus
  29. extern "C" {
  30. #endif
  31.  
  32. OSErr TLMCreateThreadPool(ThreadStyle style, short count, Size stack);
  33. OSErr TLMGetFreeThreadCount(ThreadStyle style, short *count);
  34. OSErr TLMGetSpecificThreadCount(ThreadStyle style, Size stack, short *count);
  35. OSErr TLMGetDefaultThreadStackSize(ThreadStyle style, Size *size);
  36. OSErr TLMThreadCurrentStackSpace(ThreadID id, long *free);
  37. OSErr TLMNewThread(ThreadStyle style,
  38.     ThreadEntryProcPtr entry,
  39.     void *param,
  40.     Size stack,
  41.     ThreadOptions options,
  42.     void **result,
  43.     ThreadID *id);
  44. OSErr TLMDisposeThread(ThreadID id, void *result, Boolean recycle);
  45. OSErr TLMGetCurrentThread(ThreadID *id);
  46. OSErr TLMYieldToAnyThread(void);
  47. OSErr TLMThreadBeginCritical(void);
  48. OSErr TLMThreadEndCritical(void);
  49. OSErr TLMYieldToThread(ThreadID id);
  50. OSErr TLMGetThreadState(ThreadID id, ThreadState *state);
  51. OSErr TLMSetThreadState(ThreadID id, ThreadState state, ThreadID suggested);
  52. OSErr TLMSetThreadStateEndCritical(ThreadID id, ThreadState state, ThreadID suggested);
  53. OSErr TLMGetThreadCurrentTaskRef(ThreadTaskRef *task);
  54. OSErr TLMGetThreadStateGivenTaskRef(ThreadTaskRef task, ThreadID id, ThreadState *state);
  55. OSErr TLMSetThreadReadyGivenTaskRef(ThreadTaskRef task, ThreadID id);
  56. OSErr TLMSetThreadScheduler(ThreadSchedulerProcPtr scheduler);
  57. OSErr TLMSetThreadSwitcher(ThreadID id, ThreadSwitchProcPtr switcher,
  58.         void *param, Boolean inout);
  59.  
  60. #if ! defined(THREAD_MANAGER_AS_THREAD_LIBRARY) && ! defined(THREAD_LIBRARY_AS_THREAD_MANAGER)
  61.     #define THREAD_MANAGER_AS_THREAD_LIBRARY (1)
  62. #endif
  63.  
  64. #if THREAD_MANAGER_AS_THREAD_LIBRARY
  65.  
  66.     #define CreateThreadPool                    TLMCreateThreadPool
  67.     #define GetFreeThreadCount                    TLMGetFreeThreadCount
  68.     #define GetSpecificThreadCount            TLMGetSpecificThreadCount    
  69.     #define GetDefaultThreadStackSize        TLMGetDefaultThreadStackSize    
  70.     #define ThreadCurrentStackSpace            TLMThreadCurrentStackSpace
  71.     #define NewThread                                TLMNewThread
  72.     #define DisposeThread                        TLMDisposeThread    
  73.     #define GetCurrentThread                    TLMGetCurrentThread        
  74.     #define YieldToAnyThread                    TLMYieldToAnyThread    
  75.     #define ThreadBeginCritical                TLMThreadBeginCritical    
  76.     #define ThreadEndCritical                    TLMThreadEndCritical
  77.     #define YieldToThread                        TLMYieldToThread
  78.     #define GetThreadState                        TLMGetThreadState
  79.     #define SetThreadState                        TLMSetThreadState
  80.     #define SetThreadStateEndCritical        TLMSetThreadStateEndCritical            
  81.     #define GetThreadCurrentTaskRef            TLMGetThreadCurrentTaskRef    
  82.     #define GetThreadStateGivenTaskRef        TLMGetThreadStateGivenTaskRef    
  83.     #define SetThreadReadyGivenTaskRef        TLMSetThreadReadyGivenTaskRef        
  84.     #define SetThreadScheduler                    TLMSetThreadScheduler    
  85.     #define SetThreadSwitcher                    TLMSetThreadSwitcher        
  86.  
  87. #elif THREAD_LIBRARY_AS_THREAD_MANAGER
  88.  
  89.     #define TLMCreateThreadPool                CreateThreadPool
  90.     #define TLMGetFreeThreadCount                GetFreeThreadCount
  91.     #define TLMGetSpecificThreadCount        GetSpecificThreadCount    
  92.     #define TLMGetDefaultThreadStackSize    GetDefaultThreadStackSize    
  93.     #define TLMThreadCurrentStackSpace        ThreadCurrentStackSpace
  94.     #define TLMNewThread                            NewThread
  95.     #define TLMDisposeThread                    DisposeThread    
  96.     #define TLMGetCurrentThread                GetCurrentThread        
  97.     #define TLMYieldToAnyThread                YieldToAnyThread    
  98.     #define TLMThreadBeginCritical            ThreadBeginCritical    
  99.     #define TLMThreadEndCritical                ThreadEndCritical
  100.     #define TLMYieldToThread                    YieldToThread
  101.     #define TLMGetThreadState                    GetThreadState
  102.     #define TLMSetThreadState                    SetThreadState
  103.     #define TLMSetThreadStateEndCritical    SetThreadStateEndCritical            
  104.     #define TLMGetThreadCurrentTaskRef        GetThreadCurrentTaskRef    
  105.     #define TLMGetThreadStateGivenTaskRef    GetThreadStateGivenTaskRef    
  106.     #define TLMSetThreadReadyGivenTaskRef    SetThreadReadyGivenTaskRef        
  107.     #define TLMSetThreadScheduler                SetThreadScheduler    
  108.     #define TLMSetThreadSwitcher                SetThreadSwitcher        
  109.  
  110. #endif
  111.  
  112. #ifdef __cplusplus
  113. }
  114. #endif
  115.  
  116. #endif /* THREAD_LIBRARY_MANAGER */
  117.